import { reqList, reqIndex,reqGetPeople,reqGetPeople2,reqGet } from "@/api";

const state = {
    goodInfo: [],
    shopName: {},
    people:[],
    people2:[],
    name:''
};

const mutations = {
    GETLIST(state, goodInfo) {
        state.goodInfo = goodInfo
    },
    GETINDEX(state, shopName) {
        state.shopName = shopName;
    },
    REQGETPEOPLE(state,people) {
        state.people = people;
    },
    GETPEOPLE2(state,people2) {
        state.people2 = people2;
    },
    REQGET(state,name) {
        state.name = name;
    }
};

const actions = {
    // 获取产品信息的action
    async getList({ commit }) {
        const result = await reqList();
        if (result.code == 1) {
            commit("GETLIST", result.data)
        }
    },
    async getShop({ commit }) {
        const result = await reqIndex();
        if (result.code == 1) {
            commit("GETINDEX", result.data);
        }
    },
    async getPeople({commit}) {
        const result = await reqGetPeople();
        if(result.code == 1) {
            commit("REQGETPEOPLE",result.data);
        }
    },
    async getPeople2({commit},number) {
        const result = await reqGetPeople2(number);
        if(result.code == 1) {
            commit("GETPEOPLE2",result.data);
        }
    },
    async reqGet({commit},name) {
        const result = await reqGet(name);
        if(result.code == 1) {
            commit("REQGET",result.data);
        }
    },
};

const getters= {}

export default {
    state,
    actions,
    mutations,
    getters
}